Skip to content

data migration to rename topic title #6669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/taxonomy/topics_by_product.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ products:
- title: Tracking protection
description: Enable tracking protection to enhance your privacy.
subtopics:
- title: Cookies
- title: Cookies as trackers
description: Troubleshoot cookies issues.
- title: Search, tag, and share
description: Learn about search functionality and how to organize or share content
Expand Down
43 changes: 43 additions & 0 deletions kitsune/products/migrations/0024_auto_20250520_1423.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 4.2.21 on 2025-05-20 14:23

from django.db import migrations


def update_topic_title(apps, schema_editor):
Topic = apps.get_model("products", "Topic")

try:
topic = Topic.objects.get(
title="Cookies",
is_archived=False,
parent__title="Tracking protection",
parent__is_archived=False,
parent__parent__title="Privacy and security",
parent__parent__is_archived=False,
parent__parent__parent__isnull=True,
)
except Topic.DoesNotExist:
print('The topic "Privacy and security > Tracking protection > Cookies" does not exist.')
except Topic.MultipleObjectsReturned:
print(
'Multiple instances of the topic "Privacy and security > Tracking protection'
' > Cookies" exist.'
)
else:
topic.title = "Cookies as trackers"
topic.save()
print(
'Successfully updated the title of the topic "Privacy and security > Tracking'
' protection > Cookies" to "Cookies as trackers".'
)


class Migration(migrations.Migration):

dependencies = [
("products", "0023_initial_topic_metadata"),
]

operations = [
migrations.RunPython(update_topic_title, migrations.RunPython.noop),
]